package Servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Impl.UserServiceImpl;
import Service.UserService;
public class LoginServlet extends HttpServlet{
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("接收到Get请求后会执行的方法!");
		//设置请求对象的数据编码格式
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		//网络数据传输，数据要么是文本字符串，要么是二进制格式的字符串
		String username = req.getParameter("username");//获取账号
		String password = req.getParameter("password");//获取密码
		UserService service = new UserServiceImpl();
		boolean result = service.login(username,password);
		PrintWriter pw = resp.getWriter();
		pw.append(String.valueOf(result));
		pw.flush();
		pw.close();
	}
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("接收到Post请求后会执行的方法!");
		
	}
	
}
